package Arrays;

import java.util.Arrays;

/**
 * 作者:hfj
 * 功能:268.丢失的数字
 * 日期: 2025/10/29 8:36
 */
public class MissingNumber {
    public static void main(String[] args) {
        int[] nums = {3,0,1};
        System.out.println(missingNumber(nums));
    }

    public static int missingNumber(int[] nums) {
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != i){
                return i;
            }
        }
        return nums[nums.length-1] + 1;
    }
}
